package com.jlz.actions.login;

import org.apache.struts2.convention.annotation.Standard;
import org.springframework.beans.factory.annotation.Autowired;

import com.jlz.beans.user.AdminBean;
import com.jlz.managers.user.Admins;

@Standard
public class ConsoleAction extends LoginBase{
	
	private @Autowired Admins admins;
	public String execute(){
		if(!this.validate()) return "admin";
		AdminBean admin = admins.find(usercode);
		if(admin == null){
			client.putError("账号或密码错误");
			return "admin";
		}
		if(!password.equals(admin.getPassword())){
			client.putError("账号或密码错误");
			return "admin";
		}
		if(!(admin.getState()==Admins.State.USING.getValue())){
			client.putError("账号暂时还不能使用！");
			return "admin";
		}
		
		client.setUser(admin);
		return "global_home_console";
	}
	
}
